<template>
  <div id="app">
    <van-nav-bar title="yogo商城" left-text="返回" left-arrow @click-left="onLeftClick" fixed />
    <div class="index">
      <router-view />
    </div>
    <TabBar />
  </div>
</template>
<script>
import TabBar from './components/Tabbar'
export default {
  components: { TabBar },
  methods: {
    onLeftClick() {
      this.$router.go(-1)
    },
    saveState() {
      console.log('保存state')
      localStorage.setItem('state', JSON.stringify(this.$store.state))
    }
  },
  mounted() {
    // window.addEventListener('load', this.saveState)
    // 监听卸载事件  文档或一个依赖资源正在被卸载。
    // window.addEventListener('unload', this.saveState)
    console.log('store.state', this.$store.state)
  }
}
</script>
<style lang='less'>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  // text-align: center;
  color: #2c3e50;
  --themeColor: #eb4450;
  width: 100%;
  height: 100vh;
  .index {
    position: relative;
    left: 0;
    top: 46px;
    width: 100%;
    height: calc(~'100vh - 96px');
    // background-color: #eee;
    overflow-y: scroll;
  }
}
div {
  box-sizing: border-box;
}
</style>
